package com.yugao.fintech.antelope.mps.api;

import com.alibaba.cloud.nacos.NacosServiceAutoConfiguration;
import com.yugao.fintech.antelope.mps.api.model.rqrs.CheckAuthUserCaptchaReq;
import com.yugao.fintech.antelope.mps.api.model.rqrs.CheckNoAuthUserCaptchaReq;
import com.yugao.fintech.antelope.mps.api.model.rqrs.MsgPushParam;
import com.yugao.fintech.antelope.mps.api.model.rqrs.SendCaptchaMsgReq;
import com.yugao.fintech.framework.assistant.utils.exception.BizException;
import com.yugao.fintech.framework.core.response.Resp;
import com.yugao.fintech.framework.core.response.RetOps;
import org.springframework.boot.autoconfigure.condition.ConditionalOnClass;
import org.springframework.cloud.openfeign.FeignAutoConfiguration;
import org.springframework.stereotype.Service;

@Service
@ConditionalOnClass({FeignAutoConfiguration.class, NacosServiceAutoConfiguration.class})
public class MsgPushCloudApiImpl implements MsgPushApi {
    @Autowired
    private MsgPushFeignApi msgPushFeignApi;

    @Override
    public void push(MsgPushParam req) {
        Resp<?> resp = msgPushFeignApi.push(req);
        RetOps.of(resp).assertSuccess((e) -> new BizException(e.getCode(), e.getMsg()));
    }

    @Override
    public void checkNoAuthUserCaptcha(CheckNoAuthUserCaptchaReq req) {
        Resp<?> resp = msgPushFeignApi.checkNoAuthUserCaptcha(req);
        RetOps.of(resp).assertSuccess((e) -> new BizException(e.getCode(), e.getMsg()));
    }

    @Override
    public void checkAuthUserCaptcha(CheckAuthUserCaptchaReq req) {
        Resp<?> resp = msgPushFeignApi.checkAuthUserCaptcha(req);
        RetOps.of(resp).assertSuccess((e) -> new BizException(e.getCode(), e.getMsg()));
    }

    @Override
    public void sendNoAuthUserCaptcha(SendCaptchaMsgReq req) {
        Resp<?> resp = msgPushFeignApi.sendNoAuthUserCaptcha(req);
        RetOps.of(resp).assertSuccess((e) -> new BizException(e.getCode(), e.getMsg()));
    }
}
